package csse3004.GD.PAdmin;

/**
 *
 * @author s4201567 Tony Yu
 */
import csse3004.GD.DA.PollAdminDA;
import java.util.ArrayList;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Tony Yu s4201567
 */
public class ReportController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());
    private PollAdminService pds = new PollAdminDA();

    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {

        PollReport pReport = pds.getPollReport();
        ArrayList<CreatorList> creators = pReport.getPollCreators();
        ArrayList<MasterList> masters = pReport.getPollMasters();
        ArrayList<pollData> polls = pReport.getPolls();
        
        ModelAndView mnv = new ModelAndView("report", "creators", creators); 
        mnv.addObject("masters", masters);
        mnv.addObject("polls", polls);
        return mnv;   
    }
}